{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "## 模型复杂度曲线"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn import datasets\n",
    "\n",
    "boston = datasets.load_boston()\n",
    "X = boston.data\n",
    "y = boston.target"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(506, 13)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=666)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAH5ZJREFUeJzt3XmUVNW99vHvr2fmoWkQukEaAkYEQUTUV6OoMYBG0ZgY\nNeaaLBNiVnxj4o1RVxLv603ujUne+BpXVGIMmYwS43A1ihE1IknUMAWRURpEaJB5bBp6qt/7x6mG\nsumuroKa6/msVaurzjlVZ9fm9NObffbZx9wdERHJLQXpLoCIiCSewl1EJAcp3EVEcpDCXUQkBync\nRURykMJdRCQHKdxFRHKQwl1EJAcp3EVEclBRunbcr18/Hzp0aLp2LyKSlRYtWrTD3Ss62y5t4T50\n6FAWLlyYrt2LiGQlM3s/lu3ULSMikoMU7iIiOUj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metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.tree import DecisionTreeRegressor\n",
    "from sklearn.metrics import r2_score\n",
    "\n",
    "maxSampleLeaf = 506\n",
    "train_scores = []\n",
    "test_scores = []\n",
    "for i in range(1, maxSampleLeaf+1):\n",
    "    dt_reg = DecisionTreeRegressor(min_samples_leaf=i)\n",
    "    dt_reg.fit(X_train, y_train)\n",
    "    y_train_predict = dt_reg.predict(X_train)\n",
    "    train_scores.append(r2_score(y_train, y_train_predict))\n",
    "    test_scores.append(dt_reg.score(X_test, y_test))\n",
    "    \n",
    "plt.plot([i for i in range(1, maxSampleLeaf+1)], train_scores, label=\"train\")\n",
    "plt.plot([i for i in range(1, maxSampleLeaf+1)], test_scores, label=\"test\")\n",
    "plt.xlim(506, 1)\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VOW9+PHPN/tCSEISkCRAguyCbAFEoaK4oNa1LaLS\n1pXq1Vttq1Vbrddf7+31dnWvRYvWBXFXVBSkxYILQtjDjmHJAmTf18k8vz/OBJKQkJkwyZnMfN+v\n17xm5pznnPnOecF3njznWcQYg1JKKf8SZHcASimlvE+Tu1JK+SFN7kop5Yc0uSullB/S5K6UUn5I\nk7tSSvkhTe5KKeWHNLkrpZQf0uSulFJ+KMSuD05MTDRpaWl2fbxSSvVKGzZsKDLGJHVWzrbknpaW\nRmZmpl0fr5RSvZKIHHSnnDbLKKWUH9LkrpRSfkiTu1JK+SHb2tzb09jYSG5uLnV1dXaH0u0iIiJI\nTU0lNDTU7lCUUn7Ip5J7bm4uMTExpKWlISJ2h9NtjDEUFxeTm5tLenq63eEopfxQp80yIrJIRApE\nJKuD/SIiT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195eAOW22PQD8\n0xgzHPin6z0iMgaYB5zhOuZZEfHLZYNEJAX4KZBhjBkLBGN993avTYB4AvjUGDMKGA/sJLCvx91Y\n16BZoF4LB/ALY8wY4CzgTleuCNTr4RljTLc9gDQgq8X73cBA1+uBWH3dAR4EHmxRbjkwvTtjs+sB\npAA5QD+scQYfARd1dG38/QHEAvtx3f/p7N+Kvz+AVKyEdT7wUSBfi3auzQfAhXo93Hv0dJv7AGPM\nYdfrI8AA1+vmhNcs17XN7xhj8oA/AoeAw0C5MWYFHV8bf5cOFAIvupoiXhCRaAL3ejwO/BJwttgW\nqNfiGBFJAyYC36DXwy223VA11s9uwHXVcbUPXomV1JKBaBGZ37JMgF2bEGAS8FdjzESgmjZ/ZgfK\n9RCR7wIFxpgNHZUJlGvRkoj0Ad4B7jHGVLTcF4jXw109ndyPishAANdzgWt7HjCoRblU1zZ/dAGw\n3xhTaIxpBN4Fzqbja+PvcoFcY8w3rvdvYyX7QLwe5wBXiMgBYAlwvoi8SmBeCwBEJBQrsb9mjHnX\ntTlgr4cnejq5LwV+7Hr9Y6w2tObt80QkXETSgeHAuh6OraccAs4SkSgREWA21s2zjq6NXzPGHAFy\nRGSka9NsYAcBeD2MMQ8aY1KNMWlYN9n/ZYyZTwBeCwDX/4+/AzuNMX9usSsgr4enum0Qk4i8DszC\nmsHtKPAI8D7wJjAYOAjMNcaUuMr/GrgZ6w75PcaYT7olMB8gIo8C12J9103ArUAfOrg2/k5EJgAv\nAGFANnATVsUjIK8HgIjMAu41xnxXRBIIwGshIjOANcA2jt+D+BVWu3vAXQ9P6QhVpZTyQzpCVSml\n/JAmd6WU8kOa3JVSyg9pcldKKT+kyV0ppfyQJnellPJDmtyVUsoPaXJXSik/9P8BmwxX/aZKdGcA\nAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x10ab844a8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "maxSampleLeaf = 100\n",
    "train_scores = []\n",
    "test_scores = []\n",
    "for i in range(1, maxSampleLeaf+1):\n",
    "    dt_reg = DecisionTreeRegressor(min_samples_leaf=i)\n",
    "    dt_reg.fit(X_train, y_train)\n",
    "    y_train_predict = dt_reg.predict(X_train)\n",
    "    train_scores.append(r2_score(y_train, y_train_predict))\n",
    "    test_scores.append(dt_reg.score(X_test, y_test))\n",
    "    \n",
    "plt.plot([i for i in range(1, maxSampleLeaf+1)], train_scores, label=\"train\")\n",
    "plt.plot([i for i in range(1, maxSampleLeaf+1)], test_scores, label=\"test\")\n",
    "plt.xlim(maxSampleLeaf, 1)\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xt4HXW97/H3N2kuTZNekrSB3gO0pRewQCm3raDsQkGh\nclQENt614ha2x3PkEbZXdO+z8XgE5QGpRXsQFRBFtBwqFBQoaoFeKKWlQEMpbVratClJmntW8jt/\nzFrJ6sptpV1rZmXW5/U8edZaM7NmfsPQT375zm9mzDmHiIiES07QDRARkdRTuIuIhJDCXUQkhBTu\nIiIhpHAXEQkhhbuISAgp3EVEQkjhLiISQgp3EZEQGhHUhsvLy9306dOD2ryIyLC0YcOGg8658YMt\nF1i4T58+nfXr1we1eRGRYcnM3k5mOZVlRERCSOEuIhJCCncRkRAKrObel46ODqqrq2ltbQ26KWlX\nWFjI5MmTycvLC7opIhJCGRXu1dXVlJSUMH36dMws6OakjXOO2tpaqqurqaysDLo5IhJCg5ZlzGyF\nmdWY2ZZ+5puZ3WFmVWa22cxOP9rGtLa2UlZWFupgBzAzysrKsuIvFBEJRjI193uBxQPMvwSYEf1Z\nCtx9LA0Ke7DHZMt+ikgwBg1359wa4NAAiywB7nOe54GxZnZ8qhooI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
      "text/plain": [
       "<matplotlib.figure.Figure at 0x108b7a550>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "maxSamplesSplit = 300\n",
    "train_scores = []\n",
    "test_scores = []\n",
    "for i in range(2, maxSamplesSplit+1):\n",
    "    dt_reg = DecisionTreeRegressor(min_samples_split=i)\n",
    "    dt_reg.fit(X_train, y_train)\n",
    "    y_train_predict = dt_reg.predict(X_train)\n",
    "    train_scores.append(r2_score(y_train, y_train_predict))\n",
    "    test_scores.append(dt_reg.score(X_test, y_test))\n",
    "    \n",
    "plt.plot([i for i in range(2, maxSamplesSplit+1)], train_scores, label=\"train\")\n",
    "plt.plot([i for i in range(2, maxSamplesSplit+1)], test_scores, label=\"test\")\n",
    "plt.xlim(maxSamplesSplit, 2)\n",
    "plt.legend()\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
